package com.sceneworker.monitorpopup;

import java.awt.event.ActionEvent;
import java.util.concurrent.Callable;

import javax.swing.tree.TreePath;

import com.jme.renderer.pass.BasicPassManager;
import com.jme.renderer.pass.Pass;
import com.jme.renderer.pass.RenderPass;
import com.jme.util.GameTaskQueueManager;

public class PassManagerMenu extends BaseMenu {

	private static final String NEW_PASS = "New Pass";
	private		BasicPassManager		mcl_mgr;
	
	public PassManagerMenu(TreePath cl_selectedPath, SceneWorkerPopUp cl_menu) {
		super(cl_menu);
		
		mcl_mgr = (BasicPassManager)cl_selectedPath.getLastPathComponent();
		
		buildMenu();
	}

	@Override
	public void actionPerformed(ActionEvent cl_e) {
		if(cl_e.getActionCommand().equals(NEW_PASS)) {
			GameTaskQueueManager.getManager().update(new Callable<Void>() {
				public Void call() throws Exception {
					Pass	lcl_renderProxy = new RenderPass();
					mcl_mgr.add(lcl_renderProxy);
					return null;
				}
				
			});
		}

	}

	@Override
	protected void buildMenu() {
		mcl_menu.add(buildAMenuItem(NEW_PASS));

	}

}

